package com.example.demo.practice;

import java.util.Arrays;

/**
 * @author liweizhi
 * @date 2020/4/22 19:16
 */
public class Xor {
    public static void main(String[] args) {
        int[] arr = {1, 2};
        swap(arr, 1, 1);
        System.out.println(Arrays.toString(arr));
    }

    static void swap(int[] arr, int i, int j) {
        if (i == j) {
            return;
        }
        arr[i] = arr[i] ^ arr[j];
        arr[j] = arr[i] ^ arr[j];
        arr[i] = arr[i] ^ arr[j];
    }
}
